package com.orange.modules.dao;

import java.sql.SQLException;

import javax.annotation.Resource;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.orange.dbhelp.DbHelper;
import com.orange.modules.entity.AuthSysValue;

@Repository
public class AuthSysValueRepository {
	
	@Resource(name = "dbHelper")
	private DbHelper dbHelper;
	
	@Autowired
	private AuthSysValueDao authSysValueDao;
	/**
	 * 根据参数类型获取参数值
	 * @param type
	 * @return
	 * @throws SQLException
	 */
	public AuthSysValue getSysValue(String type) throws SQLException{
		String sql = "SELECT t.p_id as pid,t.sys_value as sysvalue,t.remark as remark,t.s_type as type  " +
				" FROM t_auth_sys_value t WHERE t.s_type =?";
		AuthSysValue asv = dbHelper.getBean(sql, AuthSysValue.class,type);
		return asv;
	}
	
	/**
	 * 修改系统参数
	 * @param asv
	 * @throws SQLException
	 */
	public void updateSysValue(AuthSysValue asv) throws SQLException{
		if(asv!=null)
			authSysValueDao.save(asv);
	}
	
}
